package com.ihr360.payroll.model.dto.staff.embeddable;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.ihr360.payroll.model.dto.salary.profile.CompanySalaryProfile;
import com.ihr360.payroll.type.SalaryProfileChangeType;
import org.hibernate.annotations.Type;

import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import java.util.Date;

/**
 * 员工薪资档案
 */
@Embeddable
public class SalaryProfile {
    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(nullable = false)
    protected CompanySalaryProfile companySalaryProfile;

    /**
     * key 值为 SalaryProfileField的code值
     */
    @Column(columnDefinition = "text", name = "items")
    @Type(type = "json-encrypt")
    private SalaryProfileItemsWrapper wrapper;

    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    @Column(columnDefinition = "date default 0", nullable = false)
    private Date effectiveAt;

    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    @Column(columnDefinition = "date")
    private Date inValidAt;


    @Column(nullable = false)
    @Enumerated(EnumType.STRING)
    private SalaryProfileChangeType changeType;


    public CompanySalaryProfile getCompanySalaryProfile() {
        return companySalaryProfile;
    }

    public void setCompanySalaryProfile(CompanySalaryProfile companySalaryProfile) {
        this.companySalaryProfile = companySalaryProfile;
    }

    public SalaryProfileItemsWrapper getWrapper() {
        return wrapper;
    }

    public void setWrapper(SalaryProfileItemsWrapper wrapper) {
        this.wrapper = wrapper;
    }

    public Date getEffectiveAt() {
        return effectiveAt;
    }

    public void setEffectiveAt(Date effectiveAt) {
        this.effectiveAt = effectiveAt;
    }

    public Date getInValidAt() {
        return inValidAt;
    }

    public void setInValidAt(Date inValidAt) {
        this.inValidAt = inValidAt;
    }

    public SalaryProfileChangeType getChangeType() {
        return changeType;
    }

    public void setChangeType(SalaryProfileChangeType changeType) {
        this.changeType = changeType;
    }
}